<?php
namespace Home\Controller;
use Think\Controller;
class AboutUsController extends Controller {
    public function index(){
        $pname = I("get.cname");
        if($pname){
            $where["pname"] = $pname;
        }else{
            $url = $_SERVER['PHP_SELF'];
            $categorys = substr(strstr($url,'php/'),4); //URL不带入口名称
            $category = strstr($categorys,'/',true);    //控制器名称
            $id = M("category") -> where(array("pname" => $category)) -> getField("id");
            $where["pname"] = M("category") -> where(array("pid" => $id)) -> limit(1) -> getField("pname");
        }
        if($pname == 'hydw'){
            $count = M("article") -> where("pid = 4") -> count();
            $page = new \Think\Page($count,15);
            $page -> setConfig('header',"<div class='subPage'>共%TOTAL_ROW%条</div>");
            $page -> setConfig('first','首页');
            $page -> setConfig('prev','上一页');
            $page -> setConfig('next','下一页');
            $page -> setConfig('link','indexpagenumb');//pagenumb 会替换成页码
            $page -> setConfig('theme',' %FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END%');
            $show = $page -> show();
            $article = M("article") -> where("pid = 4") ->limit($page -> firstRow.','.$page -> listRows) -> select();
            $this -> assign('article',$article);
            $this -> assign('page',$show);
            $this->display("AboutUs:hydw");
        }
    	$AboutUs = M("category") -> where($where) -> select();
    	$this -> assign('AboutUs',$AboutUs[0]);
        $this->display();
    }

    public function hydw(){
        $this->display();
    }
}